<template>
  <!--用户添加&修改-->
  <div class="search">
    <f-form ref="form" :action="api.role" :form-key="this.formItem.roleId">
      <f-form-item label="角色名称" name="roleName" :required="true" :value="formItem.roleName"/>
      <f-form-item label="角色编码" name="roleCode" :required="true" :value="formItem.roleCode"/>
      <f-form-item label="描述" name="roleDesc" type="textarea" :value="formItem.roleDesc"/>
    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'roleForm',
    props: {},
    data () {
      return {
        isAdd: true,
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem () {
        return {
          roleId: '',
          roleName: '',
          roleCode: '',
          status: '',
          roleDesc: ''
        }
      },
      setData (data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        this.isAdd = true
        if (data && data.roleId) {
          this.formItem = data
          this.isAdd = false
        }
      },
      handleSubmit (callback) {
        this.$refs.form.submit({}, callback)
      }
    },
    created () {

    },
    beforeDestroy () {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
